package com.example.nutritionmanager.event

import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.asSharedFlow

object EventBus {
    // 使用 SharedFlow 作为事件总线（支持粘性事件）
    private val _events = MutableSharedFlow<Any>(replay = 1)
    val events = _events.asSharedFlow()

    // 发送事件
    suspend fun post(event: Any) {
        _events.emit(event)
    }

}
sealed class IntakeRefreshEvent {
    data class DateChanged(val newDate: String) : IntakeRefreshEvent()
    object RefreshData : IntakeRefreshEvent()
    data class ErrorOccurred(val message: String) : IntakeRefreshEvent()
}